home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / man / catn / uplevel.n < prev    next >
Text File  |  1994-09-20  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4. uplevel(n)            Tcl Built-In Commands
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NAME
  11.      uplevel - Execute a script in a different stack frame
  12.  
  13. SYNOPSIS
  14.      uplevel ?_l_e_v_e_l? _a_r_g ?_a_r_g ...?
  15. _________________________________________________________________
  16.  
  17.  
  18. DESCRIPTION
  19.      All of the _a_r_g arguments are concatenated  as  if  they  had
  20.      been  passed  to concat; the result is then evaluated in the
  21.      variable context indicated by _l_e_v_e_l.   Uplevel  returns  the
  22.      result of that evaluation.
  23.  
  24.      If _l_e_v_e_l is an integer then it gives a distance (up the pro-
  25.      cedure  calling stack) to move before executing the command.
  26.      If _l_e_v_e_l consists of # followed by a number then the  number
  27.      gives an absolute level number.  If _l_e_v_e_l is omitted then it
  28.      defaults to 1.  _L_e_v_e_l cannot be defaulted if the first  _c_o_m_-
  29.      _m_a_n_d argument starts with a digit or #.
  30.  
  31.      For example, suppose that procedure a was invoked from  top-
  32.      level,  and  that it called b, and that b called c.  Suppose
  33.      that c invokes the uplevel command.  If _l_e_v_e_l is 1 or #2  or
  34.      omitted,  then  the command will be executed in the variable
  35.      context of b.  If _l_e_v_e_l is 2 or #1 then the command will  be
  36.      executed  in the variable context of a.  If _l_e_v_e_l is 3 or #0
  37.      then the command will be executed at top-level (only  global
  38.      variables will be visible).
  39.  
  40.      The uplevel command causes the invoking procedure to  disap-
  41.      pear  from  the procedure calling stack while the command is
  42.      being executed.  In the above example, suppose c invokes the
  43.      command
  44.  
  45.           uplevel 1 {set x 43; d}
  46.  
  47.      where d is another Tcl  procedure.   The  set  command  will
  48.      modify  the variable x in b's context, and d will execute at
  49.      level 3, as if called from b.  If it in  turn  executes  the
  50.      command
  51.  
  52.           uplevel {set x 42}
  53.      then the set command will modify the same variable x in  b's
  54.      context:   the procedure c does not appear to be on the call
  55.      stack when d is executing.  The command ``info  level''  may
  56.      be used to obtain the level of the current procedure.
  57.  
  58.      Uplevel makes it possible  to  implement  new  control  con-
  59.      structs  as  Tcl  procedures  (for example, uplevel could be
  60.  
  61.  
  62.  
  63. Tcl                                                             1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. uplevel(n)            Tcl Built-In Commands
  71.  
  72.  
  73.  
  74.      used to implement the while construct as a Tcl procedure).
  75.  
  76.  
  77. KEYWORDS
  78.      context, stack frame, variables
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Tcl                                                             2
  130.  
  131.  
  132.  
  133.